package com.hongyuan.venue.ui.main.activity;

import android.os.Bundle;

import androidx.lifecycle.ViewModelProviders;

import com.hongyuan.venue.R;
import com.hongyuan.venue.base.AppViewModelFactory;
import com.hongyuan.venue.base.CustomActivity;
import com.hongyuan.venue.data.Constants;
import com.hongyuan.venue.data.md5.EncryptionUtil;
import com.hongyuan.venue.databinding.ActivityStartupPageBinding;
import com.hongyuan.venue.ui.main.view_mode.StartupPageViewModel;

import me.tatarka.bindingcollectionadapter2.BR;

public class StartupPageActivity extends CustomActivity<ActivityStartupPageBinding, StartupPageViewModel> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_startup_page;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public StartupPageViewModel initViewModel() {
        //使用自定义的ViewModelFactory来创建ViewModel，如果不重写该方法，则默认会调用LoginViewModel(@NonNull Application application)构造方法
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(StartupPageViewModel.class);
    }

    @Override
    public void initData() {
        super.initData();

        //关闭加载框的显示
        noShowLoading = true;

        //请求token信息
        viewModel.clearParams().setParams("client","Android").setParams("at_name","fit").setParams("at_pwd", EncryptionUtil.md5DecodeTwo("123456"));
        viewModel.requestData(Constants.GET_TOKEN);
    }
}
